﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Text;
using RESTServices.Dominio;

namespace RESTServices.Persistencia
{
    public class CiudadanoDAO
    {

        public Ciudadano ObtenerXDNI(string dni)
        {
            string sql = " SELECT * FROM RENIEC_PERSONA  WHERE DNI= @DNI ";

            SqlCommand sqlCommand = new SqlCommand();
            sqlCommand.Parameters.Add("@DNI", dni);
            sqlCommand.CommandText = sql;

            using (DataAccessRENIEC adoDataService = new DataAccessRENIEC())
            {
                Ciudadano oCiudadano = new Ciudadano();
                IDataReader dr = adoDataService.ExecuteReader(sqlCommand);

                if (dr.Read())
                {
                    oCiudadano.DNI =(string)dr["DNI"];
                    oCiudadano.NOMBRE = (string)dr["NOMBRE"];
                    oCiudadano.APEPAT = (string)dr["APEPAT"];
                    oCiudadano.APEMAT = (string)dr["APEMAT"];
                }
                dr.Close();
                adoDataService.Dispose();

                return oCiudadano;
            }


             
        }
    }
}